<html>
<head><meta charset="utf-8"><title>future-contract-clarify · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-contract-clarify.html">future-contract-clarify</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213349204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-contract-clarify/near/213349204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-contract-clarify.html#213349204">(Oct 14 2020 at 20:53)</a>:</h4>
<p>Looking at the future contract, it doesn't specify many details about how wakers should be stored and purged. This came to mind after a discussion on <code>Wake</code> trait stabilization issue where dtolnay stated:</p>
<p>"Correctly implemented futures will not leak tasks, because they should not hold the Waker in their yielding state."</p>
<p>I understand this as "a waker should only be stored in conjunction with a Poll::Pending return value, and once it is polled again, it should be cleared (or replaced with the new waker)"</p>
<p>However, this doesn't seem to be true for all futures. For instance, when <code>future::select(a, b)</code> yields <code>Ready(Either::Right(_, pending_fut))</code> AND "a" is still pending, a can for sure hold on to the waker. Is this a bug? Anyone who can clarify the rules for storing wakers?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>